package GUI;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import Control.Ctr;
import Model.Coach;

public class CoachTable extends AbstractTableModel {

private static final String[] columnNames = { "Id", "SSN" , "Coach Name", "Address", "Phone" };
private Ctr ctr;

private ArrayList<Coach> Coach;
public CoachTable(){
	Coach = new ArrayList<Coach>();
	ctr = new Control.Ctr();

	for(Coach e : ctr.findAllCoach() )
	{Coach.add(e);
	}
}
public CoachTable(Coach c)
{	ctr = new Control.Ctr();
	Coach = new ArrayList<Coach>();
	Coach.add(c);}

@Override
public int getColumnCount() {
    // 
    return columnNames.length;
}

@Override
public int getRowCount() {
    return Coach.size();
}

@Override
public String getColumnName(int column) {
    return columnNames[column];
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
     {
    	switch (columnIndex){
   case 0:
        return Coach.get(rowIndex).getchID();
    case 1:
    	return Coach.get(rowIndex).getSsn();
    case 2:
    	
        return Coach.get(rowIndex).getName();
    case 3:
    	
    	return Coach.get(rowIndex).getAddress();
    case 4:
        return Coach.get(rowIndex).getPhone();
    
    			}
    }
    
    return null;
}   
}
